<?php

namespace App\Console\Commands;

use App\Models\mcds_users;
use Illuminate\Console\Command;
use Ixudra\Curl\Facades\Curl;

class Hello extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'make:hello';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'hello';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $id = 25302404;
        $pageSize = 2000;
        $url = "https://minapp.mcdonalds.com.cn/api/test/getusers";
        while (1){
                $dataRes = Curl::to($url)
                    ->withData(['pageSize'=>$pageSize,'id'=>$id])
                    ->post();
                $data = json_decode($dataRes,true);
                if($data['result']==1){
                    $res = mcds_users::insert($data['data']);
                    $id += ($pageSize+1);
                    savelog('user_result', ''.$res.'id：'.$id);
                }else{
                    savelog('user_result', '错误id：'.$id);
                }


        }
    }
}
